package day03;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class A07_IndexServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        //从会话域中获取到刚才存的用户名和密码
        HttpSession session = req.getSession();
        Object username = session.getAttribute("username");
        Object password = session.getAttribute("password");
        //响应给浏览器一句话"欢迎你: 用户名 和 密码"
        resp.getWriter().write("欢迎你:"+username+password);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            doGet(req, resp);
    }
}
